<?php

/**
 * This file is part of the Pagizer package.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @copyright   Copyright (c) 2010 Advisa (http://www.advisa.fr)
 * @author      Pagizer Core Team <team@pagizer.org>
 * @package     Pagizer
 * @subpackage  backoffice
 */

abstract class m_backoffice_extends_Action extends f_core_Action
{
    public function getRequestDocument()
    {
        $docId = $this->getRequestParameter('docId');
        $docLang = $this->getRequestParameter('docLang', $this->getContext()->getDefaultLang());

        if(!is_null($docId) && !is_null($docLang))
        {
            return $this->getDocumentProvider()->getByUniqueId($docId, $docLang);
        }

        return null;
    }

    /**
     * Default validate action
     * @return boolean
     */
    public function validate()
    {
        return $this->getUserContext()->hasRight("backoffice_accessBo");
    }

    /**
     * Default errorHandler
     * @return string
     */
    public function errorHandler()
    {
        return f_template_Template::getInstance()->setModuleTemplate('backoffice', 'block/NoRights.html')->render();
    }
}